﻿<?php
require ("webfunc.php");

$origURL= '/home.do';
$globalsid = '';
if(array_key_exists('email',$_GET))
{
	$useremail = $_GET['email'];
	if($useremail == 'flamepjlh@126.com')
		$globalsid = $global_126;
	if($useremail == 'flamepjlh@163.com')
		$globalsid = $global_163;
	if($useremail == 'fxckgfw1@gmail.com')
		$globalsid = $global_gmail;
}
else
{
	$useremail = 'flamepjlh@126.com';
}
if(array_key_exists('pwd',$_GET))
{
	$userpwd = $_GET['pwd'];
}
else
{
	$userpwd = 'flamehjhj';
}
$login = '登录';
$curlPost = 'origURL='  . urlencode($origURL) . '&email=' . urlencode($useremail) . '&password='. urlencode($userpwd). '&login='. urlencode($login);
//$data = vlogin('http://3g.renren.com/login.do?fx=0&autoLogin=true', $curlPost);
$loginurl = 'http://3g.renren.com/home.do?sid='.$globalsid;
$data = vget($loginurl);
$ret1 = strip_tags($data, "<a>");
$ret2 = substr($ret1, strpos($ret1, 'sid='));
$sid = substr($ret2, strpos($ret2, 'sid='),strpos($ret2, '&amp') - strpos($ret2, 'sid='));
$ret1 = substr($ret1, strpos($ret1, 'http://mapp.renren.com/apps.do?'));
$appurl = substr($ret1, strpos($ret1, 'http://mapp.renren.com/apps.do?'), strpos($ret1, '>应用<') - strpos($ret1, 'http')-1);
$data = vget('http://mapps.renren.com/rr_farm/farm/action/wap,indexAction.php?'.$sid);
//$data = vget($appurl);
//$ret1 = substr($data, strpos($data, 'http://mapp.renren.com/apphistory.do?appid=53429'));
//$appurl = substr($ret1, strpos($ret1, 'http'), strpos($ret1, 'htf=751') - strpos($ret1, 'http')+7);
//$data = vget($appurl);
$coloreig = '/rr_farm/farm/action/wap,indexAction.php?&svv=1';
$appmainurl = 'http://mapps.renren.com';
$cropeig = '/rr_farm/farm/action/wap,myCropAction';
$treeeig = '/rr_farm/farm/action/wap,myTreeAction';
$animaleig = '/rr_farm/farm/action/wap,myAnimalAction';
$machineeig = '/rr_farm/farm/action/wap,myMachineAction';
$friendeig = '/rr_farm/farm/action/wap,myFriendsListAction';
if (strpos($data, $coloreig))
{
	$ret1 = substr($data, strpos($data, $coloreig));
	$simpleurl = $appmainurl.substr($ret1, strpos($ret1, $coloreig), strpos($ret1, ">简版") - strpos($ret1, $coloreig) - 1);
	$data = vget($simpleurl);
}
$cropurl = $appmainurl.substr($data, strpos($data, $cropeig), strpos($data, ">【农田】") - strpos($data, $cropeig) - 1);
$treeurl = $appmainurl.substr($data, strpos($data, $treeeig), strpos($data, ">【果树】") - strpos($data, $treeeig) - 1);
$animalurl = $appmainurl.substr($data, strpos($data, $animaleig), strpos($data, ">【畜牧】") - strpos($data, $animaleig) - 1);
$machineurl = $appmainurl.substr($data, strpos($data, $machineeig), strpos($data, ">【机械】") - strpos($data, $machineeig) - 1);
$friendurl = $appmainurl.substr($data, strpos($data, $friendeig), strpos($data, ">【好友农场】") - strpos($data, $friendeig) - 1);
$reapalleig = '/rr_farm/farm/action/wap,reapAllAction';
if (strpos($data, "【农田】★"))
{
	$cropdata = vget($cropurl);
	$reapallcropurl = $appmainurl.substr($cropdata, strpos($cropdata, $reapalleig), strpos($cropdata, ">收获全部农产品") - strpos($cropdata, $reapalleig) - 1);
	$reapalldata = vget($reapallcropurl);
	echo($reapalldata);
}
if (strpos($data, "【果树】★"))
{
	$treedata = vget($treeurl);
	$reapalltreeurl = $appmainurl.substr($treedata, strpos($treedata, $reapalleig), strpos($treedata, ">收获全部果树产品") - strpos($treedata, $reapalleig) - 1);
	$reapalldata = vget($reapalltreeurl);
	echo($reapalldata);
}
if (strpos($data, "【畜牧】★"))
{
	$animaldata = vget($animalurl);
	if (strpos($animaldata, "收获全部畜牧产品"))
	{
			$reapallanimalurl = $appmainurl.substr($animaldata, strpos($animaldata, $reapalleig), strpos($animaldata, ">收获全部畜牧产品") - strpos($animaldata, $reapalleig) - 1);
			$reapalldata = vget($reapallanimalurl);
			echo($reapalldata);
	}
}
if (strpos($data, "【机械】★"))
{
	$machinedata = vget($machineurl);
	if (strpos($machinedata, "收获全部加工产品"))
	{
			$reapallanimalurl = $appmainurl.substr($machinedata, strpos($machinedata, $reapalleig), strpos($machinedata, ">收获全部加工产品") - strpos($machinedata, $reapalleig) - 1);
			$reapalldata = vget($reapallanimalurl);
			echo($reapalldata);
	}
}
delcookie($cookie_file);
?>